<?php

/**
 * LEAGUEMan
 *
 * Copyright (C) 2007 Marko Bischof
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

class LM_Table_Club extends LM_Table
{
    /** @var int Primary Key */
    public $id;
    /** @var string name */
    public $name;
    /** @var string text */
    public $text;
    /** @var int year of foundation */
    public $founded;
    /** @var int count(members) */
    public $cntMembers;
    /** @var string colors */
    public $colors;
    /** @var string logo */
    public $logo;
    /** @var string address */
    public $address;
    /** @var string zipcode */
    public $zipcode;
    /** @var string city */
    public $city;
    /** @var string country code */
    public $country;
    /** @var string homepage */
    public $internet;
    /** @var string phone1 */
    public $phone1;
    /** @var string phone2 */
    public $phone2;
    /** @var string title */
    public $stadiumTitle;
    /** @var string address */
    public $stadiumAddress;
    /** @var string zipcode */
    public $stadiumZipcode;
    /** @var string city */
    public $stadiumCity;
    /** @var int capacity */
    public $stadiumCapacity;
    /** @var string gmap_lat_value */
    public $stadiumGmapLat;
    /** @var string gmap_lng_value */
    public $stadiumGmapLng;
    /** @var timestamp created */
    public $created;
    /** @var int references mosUser */
    public $createdBy;
    /** @var int published */
    public $published;


    public function __construct($db)
    {
        parent::__construct('#__leagueman_club', 'id', $db);
    }

    public function getID()
    {
        return $this->id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function getText()
    {
        return $this->text;
    }

    public function getFounded()
    {
        return $this->founded;
    }

    public function getMembers()
    {
        return $this->cntMembers;
    }

    public function getColors()
    {
        return $this->colors;
    }

    public function getLogo()
    {
        return $this->logo;
    }

    public function getAddress()
    {
        return $this->address;
    }

    public function getZipcode()
    {
        return $this->zipcode;
    }

    public function getCity()
    {
        return $this->city;
    }

    public function getCountry()
    {
        return $this->country;
    }

    public function getHomepage()
    {
        return $this->internet;
    }

    public function getPhone1()
    {
        return $this->phone1;
    }

    public function getPhone2()
    {
        return $this->phone2;
    }

    public function getStadiumTitle()
    {
        return $this->stadiumTitle;
    }

    public function getStadiumAddress()
    {
        return $this->stadiumAddress;
    }

    public function getStadiumZipcode()
    {
        return $this->stadiumZipcode;
    }

    public function getStadiumCity()
    {
        return $this->stadiumCity;
    }

    public function getStadiumCapacity()
    {
        return $this->stadiumCapacity;
    }

    public function getGMapLat()
    {
        return $this->stadiumGmapLat;
    }

    public function getGMapLng()
    {
        return $this->stadiumGmapLng;
    }

    public function getGmapLatLng()
    {
        return $this->getGMapLat() . "," . $this->getGMapLng();
    }

    public function getPublished()
    {
        return $this->published;
    }

    public function getTeams()
    {
        $database = $this->_db;

        $database->setQuery("SELECT * FROM jos_leagueman_team WHERE team_club = " . $database->Quote($this->id));
        return $database->loadObjectList();
    }

    public function check()
    {
        global $my;

        if (!$my->id) {
            return false;
        }

        $this->created = date("Y-m-d H:i:s");
        $this->createdBy = $my->id;

        if (empty($this->name)) {
            return false;
        } else {
            return true;
        }

    }
}